#include<bits/stdc++.h>

using namespace std;
using ll = long long;
#define endl '\n'


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    deque<int> Q;
    for (int i = n - 1; i >= 0; i--) {
        if (Q.size() > 1) {
            int x = Q.back();
            Q.pop_back();
            Q.push_front(x);
        }
        Q.push_front(a[i]);

    }
    cout << n << endl;
    while (Q.size()) {
        cout << Q.front() << " ";
        Q.pop_front();
    }


    return 0;
}